#pragma once
#include <qbprotocol/include/SSFilters.h>

#include <list>
#include <map>
#include <string>

#include "../BondInfo.h"
#include "../bondlib.h"

class IBrokerKeyDest;
class CBondBankRep;
class CBondCompanyRep;
class CCFETSQuoteRep;
class S_BONDLIB_EXPORT CBondFilter {
  typedef std::map<int, CBondInfo> CBondInfoMap;
  BLHCONDITION* m_condition;
  BLHCONDITION m_condition_temp;
  bool bAll;
  bool m_use_condition;
  std::list<std::string> m_brokls;
  bool m_checkbonds;
  CBondInfoMap m_listedbonds;

 public:
  static CBondBankRep* GetBankRep(int nIndex);
  static CBondBankRep* GetClntRep(int nIndex);
  static CBondCompanyRep* GetCompanyRep(int nIndex);
  static CBondCompanyRep* GetBrokerMixedBPRep(int nIndex);
  static CCFETSQuoteRep* GetCFETSRep(int nIndex);
  static int GetAllBondsSize();

  CBondFilter();
  void SetCondition(BLHCONDITION* blh, bool bAll);
  void SetBrokers(const std::list<std::string>& brokers);
  bool ProcessBond(int nTmpKey, IBrokerKeyDest* dest, void* context);
  bool ProcessBondBrokerMixedBP(int nTmpKey, IBrokerKeyDest* dest,
                                void* context);
  bool ProcessBondCFETS(int nType, int nTmpKey, IBrokerKeyDest* dest,
                        void* context);
  bool ProcessBondCFETSDeal(int nTmpKey, IBrokerKeyDest* dest, void* context);
  bool ProcessBondSSEFI(int nTmpKey, IBrokerKeyDest* dest, void* context);
  void BeforeReloads();
  void AfterReloads();
  void CheckBonds(int bid);

  BLHCONDITION* GetCondition();
};
